home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / misc / TCS.lha / TCS / demos / cod / XPfld.s < prev   
Encoding:
Text File  |  2000-09-26  |  10.7 KB  |  316 lines

  1. *******************************************************************************
  2. * Cross Playfield example
  3. *******************************************************************************
  4. * INFO    loads three 320x256x8 ILBMs and applies some (cross-)fading
  5. *    effects in (Dual) Cross Playfield mode
  6. * NOTE    - optionally you can pass as CLI argument the names other
  7. *      320x256x8 ILBMs to load (yours must have the same size and
  8. *      must respect all the restrictions of TCS_LdILBM(), otherwise
  9. *      the program won't execute or the graphics will look bad -
  10. *      not dangerous, anyway!)
  11. *    - press LMB to quickly skip ahead
  12. *    - hold LMB down to exit anytime
  13. *******************************************************************************
  14.  
  15.     machine    68020
  16.  
  17.     include    INCLUDES:libraries/tcs.i
  18.     include    INCLUDES:libraries/tcs_lib.i
  19.     include    /inc/macros.i
  20.  
  21.  
  22.  
  23. *******************************************************************************
  24. * definitions
  25. *******************************************************************************
  26.  
  27. DSPLWD    =    320    ;our TCS display width and
  28. DSPLHT    =    256    ;height (LORES pixels)
  29. SCRWD    =    320    ;TCS screen width and
  30. SCRHT    =    256    ;height (FullRes pixels)
  31. DSPLX0    =    $81*4    ;display start
  32. DSPLY0    =    $2c    ;position (SHRES pixels)
  33. DSPLX1    =    DSPLX0+DSPLWD*4    ;display end
  34. DSPLY1    =    DSPLY0+DSPLHT    ;position (SHRES pixels)
  35. DSPLBRTNS    =    256    ;max brightness
  36. GFXCTXT    =    0    ;graphic context
  37. CWBTM    =    0    ;clipping
  38. CWTOP    =    0    ;window
  39. CWRT    =    0    ;borders
  40. CWLF    =    0    ;coordinates
  41. VDOMODE    =    TCS_VMf_FullRes    ;display video mode
  42.  
  43. ARGSNO    =    3    ;command line arguments No.
  44. TRNSPCOL    =    15    ;Dual Cross Playfield transparent color
  45.  
  46.  
  47.  
  48. *******************************************************************************
  49. * code start
  50. *******************************************************************************
  51.  
  52.     include    /inc/shl_strtup.i
  53.  
  54.  
  55.  
  56. *******************************************************************************
  57. * init
  58. *******************************************************************************
  59.  
  60. _PrgInit    lea.l    DsplDef,a0    ;use same DD structure to
  61.     ori.l    #TCS_VMf_FPfld,(TCS_DD_VdoMode,a0) ;init another display
  62.     CALLTCS    InitDspl    ;for the front playfield
  63.     move.l    d0,FPfldDI    ;store DI structure address
  64.     beq.s    .fail    ;if error...
  65.  
  66. *******************************************************************************
  67. * back playfield
  68.  
  69.     movea.l    CmdLnArgs,a0    ;picture #0 filename address
  70.     tst.l    a0
  71.     bne.s    .ld0    ;if filename specified...
  72.     lea.l    Pic0FlNm,a0    ;default picture #0
  73. .ld0    movea.l    ([DIAdr.l],TCS_DI_CSAdr.w),a1 ;directly to back
  74.     move.l    #SCRWD*SCRHT,d0    ;playfield screen buffer
  75.     CALLTCS    LdILBM    ;load it
  76.     cmpi.l    #TCS_PE_OK,d0    ;success?
  77.     blo.s    .fail    ;if not...
  78.  
  79.     move.b    (TCS_II_RGBxMode.w,d0.l),d2 ;get picture's RGBx mode
  80.     movea.l    d0,a0    ;free all the memory allocated
  81.     CALLTCS    UnLdILBM    ;for the ILBMInfo structure
  82.     movea.l    DIAdr,a0
  83.     move.b    d2,d0    ;RGBx mode
  84.     move.w    #DSPLBRTNS,d1
  85.     CALLTCS    SetRGBxMode    ;set back playfield palette
  86.  
  87. *******************************************************************************
  88. * front playfield
  89.  
  90.     movea.l    CmdLnArgs+4,a0    ;picture #1 filename address
  91.     tst.l    a0
  92.     bne.s    .ld1    ;if filename specified...
  93.     lea.l    Pic1FlNm,a0    ;default picture #1
  94. .ld1    movea.l    ([FPfldDI.l],TCS_DI_CSAdr.w),a1 ;directly to front
  95.     move.l    #SCRWD*SCRHT,d0    ;playfield screen buffer
  96.     CALLTCS    LdILBM    ;load it
  97.     cmpi.l    #TCS_PE_OK,d0    ;success?
  98.     blo.s    .fail    ;if not...
  99.  
  100.     move.b    (TCS_II_RGBxMode.w,d0.l),d2 ;get picture's RGBx mode
  101.     movea.l    d0,a0    ;free all the memory allocated
  102.     CALLTCS    UnLdILBM    ;for the ILBMInfo structure
  103.     movea.l    FPfldDI,a0
  104.     move.b    d2,d0    ;RGBx mode
  105.     move.w    #DSPLBRTNS,d1
  106.     CALLTCS    SetRGBxMode    ;set front playfield palette
  107.  
  108. *******************************************************************************
  109. * picture for Dual Cross Playfield
  110.  
  111.     movea.l    CmdLnArgs+8,a0    ;picture #2 filename address
  112.     tst.l    a0
  113.     bne.s    .ld2    ;if filename specified...
  114.     lea.l    Pic2FlNm,a0    ;default picture #2
  115. .ld2    suba.l    a1,a1
  116.     CALLTCS    LdILBM    ;load it
  117.     cmpi.l    #TCS_PE_OK,d0    ;success?
  118.     blo.s    .fail    ;if not...
  119.     move.l    d0,pic2IIAdr    ;store ILBMInfo structure address
  120.  
  121. *******************************************************************************
  122. * Cross Playfield / exit
  123.  
  124.     movea.l    DIAdr,a0    ;back playfield DI
  125.     movea.l    FPfldDI,a1    ;front playfield DI
  126.     CALLTCS    EnbXPfld    ;enable Cross Playfield
  127.  
  128.     move.w    #0,ccr    ;OK!
  129.     rts
  130. .fail    move.w    #4,ccr    ;signal error
  131.     rts
  132.  
  133.  
  134.  
  135. *******************************************************************************
  136. * main
  137. *******************************************************************************
  138.  
  139. _PrgMain    movea.l    FPfldDI,a0
  140.     CALLTCS    ShwDspl    ;show front playfield, too
  141.     movea.l    DIAdr,a0    ;render back playfield
  142.     CALLTCS    CPUFRPass0    ;to make pixels visible
  143.     movea.l    FPfldDI,a0    ;render front playfield
  144.     CALLTCS    CPUFRPass0    ;to make pixels visible
  145.  
  146.  
  147. *******************************************************************************
  148. * first cross-fade: the front playfield disappears behind the back playfield
  149.  
  150.     movea.l    FPfldDI,a2
  151.     move.w    #256,d2    ;opacity at beginning (max)
  152. .XFade0    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  153.     movea.l    a2,a0    ;our display
  154.     move.w    d2,d0
  155.     CALLTCS    SetFPfldOpct    ;change opacity
  156.     btst.b    #6,$bfe001    ;exit if LMB
  157.     dbeq    d2,.XFade0    ;decrease opacity and repeat other 256 times
  158.  
  159. *******************************************************************************
  160. * second cross-fade: a new picture is written to the front playfield (still
  161. * hidden) and then shown with a cross-fade-in (Dual mode)
  162.  
  163.     move.b    ([pic2IIAdr.l],TCS_II_RGBxMode.w),d0 ;get picture #2 RGBx
  164.     movea.l    a2,a0    ;mode for front playfield
  165.     move.w    #DSPLBRTNS,d1    ;maximum brightness
  166.     CALLTCS    SetRGBxMode    ;set appropriate palette
  167.  
  168.     movea.l    ([pic2IIAdr.l],TCS_II_GfxAdr.w),a0 ;picture #2 graphics address
  169.     movea.l    (TCS_DI_CSAdr,a2),a1    ;front playfield screen address
  170.     move.w    #SCRWD*SCRHT/4-1,d0    ;copy picture #2
  171. .CpyPxl    move.l    (a0)+,(a1)+    ;to front playfield
  172.     dbra    d0,.CpyPxl    ;screen
  173.  
  174.     movea.l    a2,a0    ;render front playfield
  175.     CALLTCS    CPUFRPass0    ;to make pixels visible
  176.  
  177.     movea.l    a2,a0    ;our display
  178.     moveq.l    #15,d0    ;RGBx transparent color
  179.     CALLTCS    EnbDXPfld    ;enable Dual modality
  180.  
  181.     move.w    #256,d2    ;counter
  182. .XFade1    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  183.     movea.l    a2,a0    ;our display
  184.     move.w    #256,d0    ;calculate new
  185.     sub.w    d2,d0    ;opacity
  186.     move.b    #TRNSPCOL,d1
  187.     CALLTCS    SetFPfldOpct    ;change opacity
  188.     btst.b    #6,$bfe001    ;exit if LMB
  189.     dbeq    d2,.XFade1    ;repeat other 256 times
  190.  
  191. *******************************************************************************
  192. * first fade: the front playfield is faded out, while the back playfield
  193. * remains visible
  194.  
  195.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  196.     move.w    #256,d2    ;brightness at beginning (max)
  197. .FadeOut0    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  198.     movea.l    a2,a0    ;our display
  199.     move.b    d3,d0    ;RGBx mode
  200.     move.w    d2,d1    ;brightness
  201.     CALLTCS    SetRGBxMode    ;change palette
  202.     btst.b    #6,$bfe001    ;exit if LMB
  203.     dbeq    d2,.FadeOut0    ;decrease brightness and repeat other 256 times
  204.  
  205. *******************************************************************************
  206. * second fade: the front playfield is faded in, while the back playfield is
  207. * still visible
  208.  
  209.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  210.     moveq.l    #0,d2    ;brightness at beginning (min)
  211. .FadeIn    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  212.     movea.l    a2,a0    ;our display
  213.     move.b    d3,d0    ;RGBx mode
  214.     move.w    d2,d1    ;brightness
  215.     CALLTCS    SetRGBxMode    ;change palette
  216.     addq.w    #1,d2    ;increase brightness
  217.     btst.b    #6,$bfe001
  218.     beq.s    .FadeOut    ;if LMB...
  219.     cmpi.w    #256,d2
  220.     bls.s    .FadeIn    ;repeat other 256 times
  221.  
  222. *******************************************************************************
  223. * third cross-fade: the front playfield is half-cross-faded-out
  224.  
  225.     movea.l    FPfldDI,a2    ;front playfield DI structure pointer
  226.     move.w    #128,d2    ;counter
  227. .XFade3    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  228.     movea.l    a2,a0    ;our display
  229.     move.w    d2,d0    ;calculate
  230.     addi.w    #128,d0    ;new opacity
  231.     move.b    #TRNSPCOL,d1
  232.     CALLTCS    SetFPfldOpct    ;change opacity
  233.     btst.b    #6,$bfe001    ;exit if LMB
  234.     dbeq    d2,.XFade3    ;decrease opacity and repeat other 128 times
  235.  
  236. *******************************************************************************
  237. * third fade: the back playfield is faded out, while the front playfield
  238. * remains visible
  239.  
  240. .FadeOut    movea.l    DIAdr,a2    ;back playfield DI structure pointer
  241.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  242.     move.w    #256,d2    ;brightness at beginning (max)
  243. .FadeOut1    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  244.     movea.l    a2,a0    ;our display
  245.     move.b    d3,d0    ;RGBx mode
  246.     move.w    d2,d1    ;brightness
  247.     CALLTCS    SetRGBxMode    ;change palette
  248.     btst.b    #6,$bfe001    ;exit if LMB
  249.     dbeq    d2,.FadeOut1    ;decrease brightness and repeat other 256 times
  250.  
  251. *******************************************************************************
  252. * fourth cross-fade: the front playfield is half-cross-faded-in
  253.  
  254.     movea.l    FPfldDI,a2    ;front playfield DI structure pointer
  255.     move.w    #128,d2    ;counter
  256. .XFade4    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  257.     movea.l    a2,a0    ;our display
  258.     move.w    #256,d0    ;calculate
  259.     sub.w    d2,d0    ;new opacity
  260.     move.b    #TRNSPCOL,d1
  261.     CALLTCS    SetFPfldOpct    ;change opacity
  262.     btst.b    #6,$bfe001    ;exit if LMB
  263.     dbeq    d2,.XFade4    ;decrease opacity and repeat other 128 times
  264.  
  265. *******************************************************************************
  266. * final fade: the front playfield is faded out, too
  267.  
  268.     movea.l    FPfldDI,a2    ;front playfield DI structure pointer
  269.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  270.     move.w    #256,d2    ;brightness at beginning (max)
  271. .FadeOut2    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  272.     movea.l    a2,a0    ;our display
  273.     move.b    d3,d0    ;RGBx mode
  274.     move.w    d2,d1    ;brightness
  275.     CALLTCS    SetRGBxMode    ;change palette
  276.     btst.b    #6,$bfe001    ;exit if LMB
  277.     dbeq    d2,.FadeOut2    ;decrease brightness and repeat other 256 times
  278.  
  279. *******************************************************************************
  280. * end
  281.  
  282. .exit    movea.l    FPfldDI,a0    ;hide front playfield,
  283.     CALLTCS    HideDspl    ;otherwise it can't be freed!
  284.     rts
  285.  
  286.  
  287.  
  288. *******************************************************************************
  289. * cleanup
  290. *******************************************************************************
  291.  
  292. _PrgClnUp    movea.l    pic2IIAdr,a0    ;free all the memory
  293.     CALLTCS    UnLdILBM    ;allocated for picture #2
  294.     movea.l    DIAdr,a0
  295.     CALLTCS    DsbXPfld    ;disable Cross Playfield
  296.     movea.l    FPfldDI,a0    ;free all the memory allocated
  297.     CALLTCS    FreeDspl    ;for the front playfield
  298.     rts
  299.  
  300.  
  301.  
  302. *******************************************************************************
  303. * data
  304. *******************************************************************************
  305.  
  306.     include    /inc/dat.i
  307.  
  308.     cnop    0,4
  309. FPfldDI    dc.l    0    ;front playfield DI structure address
  310. pic2IIAdr    dc.l    0    ;picture #2 ILMBInfo structure address
  311. tmplt    dc.b    "PICTURE0=P0,PICTURE1=P1,"
  312.     dc.b    "PICTURE2=P2",0    ;template for ReadArgs()
  313. Pic0FlNm    dc.b    "/pix/TigerMask.rgbp.iff",0 ;default picture #0 (back playfield)
  314. Pic1FlNm    dc.b    "/pix/Alphonse.rgbh.iff",0 ;default picture #1 (front playfield)
  315. Pic2FlNm    dc.b    "/pix/DXP.rgbh_15.iff",0    ;default picture #2 (for Dual Cross Playfield)
  316.